package com.aos.iot.socket.common.ack;

import com.aos.iot.socket.common.message.Message;

import java.lang.reflect.ParameterizedType;

public abstract class AckCallback<T extends Message> {

    protected final Class<T> resultClass = (Class<T>)((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];;

    protected final int timeout;

    public AckCallback() {
        this(-1);
    }

    public AckCallback(int timeout) {
        this.timeout = timeout;
    }

    public Class<T> getResultClass() {
        return resultClass;
    }

    public int getTimeout() {
        return timeout;
    }

    public void onTimeout() {

    }

    public abstract void onSuccess(T result);
}
